﻿<UserControl x:Class="MetaTracker.View.StatisticsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
             mc:Ignorable="d" 
             Loaded="StatisticsView_Loaded"
             d:DesignHeight="441" d:DesignWidth="1090">
    <StackPanel
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        >
        <DataGrid AutoGenerateColumns="False" 
                  Height="325" Name="dataGrid1" Width="1018" 
                  ItemsSource="{Binding WeeklyStats, 
                    UpdateSourceTrigger=PropertyChanged, 
                    diag:PresentationTraceSources.TraceLevel=High}" HorizontalContentAlignment="Center">
            <DataGrid.CellStyle>
                <Style >
                    <Setter Property="Block.TextAlignment" Value="Center"/>
                </Style>
            </DataGrid.CellStyle>
            <DataGrid.Columns>
                <DataGridTextColumn Header="Week of" 
                                    
                                    Binding="{Binding Date,StringFormat={}\{0:MM/dd/yyyy\}}" IsReadOnly="True" />
                <DataGridTextColumn Header="Max Weight"
                                    Binding="{Binding WeightMax, StringFormat={}{0:000.0}, 
                                    Converter={StaticResource NullDoubleToNA}}" IsReadOnly="True" />
                <DataGridTextColumn Header="Avg Weight"
                                    Binding="{Binding WeightAvg, StringFormat={}{0:000.0}, 
                                    Converter={StaticResource NullDoubleToNA}}" IsReadOnly="True" />
                <DataGridTextColumn Header="Min Weight"
                                    Binding="{Binding WeightMin, StringFormat={}{0:000.0}, 
                                    Converter={StaticResource NullDoubleToNA}}" IsReadOnly="True" />

                <DataGridTextColumn Header="Calories Eaten"
                                    Binding="{Binding CaloriesEaten, Converter={StaticResource NullLongToNA}}" 
                                    IsReadOnly="True" />
                <DataGridTextColumn Header="Calories Burned"
                                    Binding="{Binding CaloriesBurned, Converter={StaticResource NullLongToNA}}" 
                                    IsReadOnly="True" />
                <DataGridTextColumn Header="Caloric Difference"
                                    Binding="{Binding CaloricDifference, Converter={StaticResource NullLongToNA}}" 
                                    IsReadOnly="True" />

                <DataGridTextColumn Header="Expected Weight Change"
                                    Binding="{Binding ExpectedWeightChange, StringFormat={}{0:0.00}, 
                                    Converter={StaticResource NullDoubleToNA}}" IsReadOnly="True" />
                <DataGridTextColumn Header="Actual Weight Change"
                                    Binding="{Binding ActualWeightChange, StringFormat={}{0:0.00}, 
                                    Converter={StaticResource NullDoubleToNA}}" IsReadOnly="True" />
                <DataGridTextColumn Header="Percent Error"
                                    Binding="{Binding PercentOff}" IsReadOnly="True" />
                <!--<DataGridTemplateColumn Header="Date" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate DataType="{x:Type DateTime}">
                            <TextBlock Text="{Binding StringFormat={0:d}}"  />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->
            </DataGrid.Columns>

        </DataGrid>
        <Button Content="_Refresh" 
                Height="23" Margin="0,0,0,20"
                HorizontalAlignment="Center" 
                Name="button1" VerticalAlignment="Center" Width="75" 
                Command="{Binding RefreshCommand}"/>
        <TextBlock Margin="0,00,0,0" HorizontalAlignment="Center"
                   Visibility="{Binding IsUsingFatSecret, Converter={StaticResource BoolToHidden}}">           
            <Hyperlink NavigateUri="http://platform.fatsecret.com" 
                       RequestNavigate="Hyperlink_RequestNavigate">
                Powered by FatSecret
            </Hyperlink>
        </TextBlock>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" 
                    Visibility="{Binding IsUsingFitbit, Converter={StaticResource BoolToHidden}}">
            <TextBlock Margin="0,0,3,0" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Hyperlink NavigateUri="http://www.fitbit.com" 
                       RequestNavigate="Hyperlink_RequestNavigate">
                Data from
            </Hyperlink>
            </TextBlock>
            <TextBlock>
            <Hyperlink NavigateUri="http://www.fitbit.com" TextDecorations="none"
                       RequestNavigate="Hyperlink_RequestNavigate">
                <Image Source="../Resources/fitbit_logo_dark_50px.png" Width="50" Height="20"/>
            </Hyperlink>
            </TextBlock>
        </StackPanel>
    </StackPanel>
</UserControl>
